/*
 * File: CollectNewspaperKarel.java
 * --------------------------------
 * At present, the CollectNewspaperKarel subclass does nothing.
 * Your job in the assignment is to add the necessary code to
 * instruct Karel to walk to the door of its house, pick up the
 * newspaper (represented by a beeper, of course), and then return
 * to its initial position in the upper left corner of the house.
 */

import stanford.karel.*;

public class CollectNewspaperKarel extends SuperKarel {
	
	public void run(){
		/* move Karel to newspaper location */
		moveToNewspaper();
		
		pickUpNewsPaper();
		/* go back to origin */
		returnTuStart();
	}
	
	/* moves Karel to newspaper location */
	private void moveToNewspaper() {
		moveToWall();
		
		/* turn round the corner */
		turnRight();
		move();
		turnLeft();
		move();
	}
	
	/* picks up the beeper */ 
	private void pickUpNewsPaper() {
		pickBeeper();
	}

	/* take Karel to where all started */
	private void returnTuStart() {
		turnAround();
		moveToWall();
		turnRight();
		move();
		turnRight();
	}
	
	/* moves Karel to the wall */
	private void moveToWall(){
		while(frontIsClear()){
			move();
		}
	}
}
